<?php

require_once(WSB_MODULES_PATH . 'sherpa/models/CategoryGateway.php');

class Sherpa_CategoryLevelTwoBoxController extends WSB_Xtension_Extension
{

	/**
	 * @return string
	 */
	public function renderForBackend()
	{
		return get_class($this);
	}

	/**
	 * Index Action
	 */
	public function indexAction()
	{
		$languageId = $this->getLanguageId();
		$catId = $this->getParam('catId', 0);
		$subcatId = $this->getParam('subcatId', 0);
		if($catId > 0) {
			$gateway = new Sherpa_Model_CategoryGateway();
			$category = $gateway->fetchById($catId, $languageId);
			if($category instanceof Sherpa_Model_Category) {
				$this->_view->category = $category;
				$this->_view->sideBannerImage = $category->getSideBannerImage();
				$categories = $gateway->fetchByParentId($languageId, $catId);
				$this->_view->categories = $categories;
				$this->_view->catId = $catId;
				$this->_view->subcatId = $this->getParam('subcatId', 0);
				$this->addContent($this->_view->render('categoryleveltwobox/index.phtml'));
			}
		}
	}

}